
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('eyeData produces correct results robust_bayarri2', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results robust_bayarri2')
    result <- sampler(100000, vy, mX, prior='robust_bayarri2', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003630000000000000,0.005550000000000000,0.001810000000000000,
0.002090000000000000,0.003080000000000000,0.004250000000000000,
0.001800000000000000,0.004290000000000000,0.001970000000000000,
0.002430000000000000,0.063299999999999995,0.003560000000000000,
0.003430000000000000,0.002100000000000000,0.001810000000000000,
0.003470000000000000,0.001580000000000000,0.001790000000000000,
0.003130000000000000,0.001630000000000000,0.001760000000000000,
0.001930000000000000,0.002170000000000000,0.001630000000000000,
0.001640000000000000,0.003900000000000000,0.001750000000000000,
0.010680000000000000,0.001580000000000000,0.004210000000000000,
0.004550000000000000,0.001620000000000000,0.003010000000000000,
0.002060000000000000,0.002000000000000000,0.006530000000000000,
0.001820000000000000,0.002800000000000000,0.001750000000000000,
0.001830000000000000,0.001860000000000000,0.041939999999999998,
0.002010000000000000,0.002000000000000000,0.001670000000000000,
0.002310000000000000,0.001870000000000000,0.001790000000000000,
0.002750000000000000,0.006850000000000000,0.002110000000000000,
0.004390000000000000,0.001830000000000000,0.012040000000000000,
0.010580000000000001,0.001460000000000000,0.002100000000000000,
0.002600000000000000,0.003040000000000000,0.010840000000000001,
0.001750000000000000,0.031440000000000003,0.002550000000000000,
0.002640000000000000,0.002420000000000000,0.008090000000000000,
0.001930000000000000,0.001840000000000000,0.001630000000000000,
0.002260000000000000,0.015440000000000001,0.001690000000000000,
0.001940000000000000,0.002410000000000000,0.002050000000000000,
0.019750000000000000,0.002160000000000000,0.003120000000000000,
0.001620000000000000,0.002030000000000000,0.001650000000000000,
0.001700000000000000,0.001870000000000000,0.002020000000000000,
0.004840000000000000,0.002210000000000000,0.180909999999999987,
0.002100000000000000,0.002830000000000000,0.023709999999999998,
0.001560000000000000,0.005980000000000000,0.003290000000000000,
0.001450000000000000,0.001820000000000000,0.004790000000000000,
0.002000000000000000,0.001630000000000000,0.015400000000000000,
0.002290000000000000,0.002730000000000000,0.010740000000000000,
0.001440000000000000,0.003790000000000000,0.001830000000000000,
0.002080000000000000,0.003950000000000000,0.004430000000000000,
0.025040000000000000,0.009169999999999999,0.004500000000000000,
0.017319999999999999,0.004380000000000000,0.002230000000000000,
0.002030000000000000,0.001670000000000000,0.003960000000000000,
0.001630000000000000,0.001900000000000000,0.001770000000000000,
0.001950000000000000,0.001630000000000000,0.007680000000000000,
0.003420000000000000,0.008710000000000001,0.001770000000000000,
0.011010000000000001,0.002000000000000000,0.002010000000000000,
0.001710000000000000,0.001960000000000000,0.009169999999999999,
0.001630000000000000,0.008990000000000000,0.005180000000000000,
0.026320000000000000,0.002710000000000000,0.001620000000000000,
0.002130000000000000,0.012250000000000000,0.011990000000000001,
0.001730000000000000,0.002360000000000000,0.001610000000000000,
0.001960000000000000,0.007939999999999999,0.008550000000000000,
0.004140000000000000,0.001560000000000000,0.001760000000000000,
0.003040000000000000,0.002770000000000000,0.945649999999999991,
0.006070000000000000,0.033470000000000000,0.001860000000000000,
0.009320000000000000,0.008970000000000001,0.015540000000000000,
0.002340000000000000,0.006390000000000000,0.007110000000000000,
0.003080000000000000,0.017059999999999999,0.002330000000000000,
0.002200000000000000,0.001490000000000000,0.002620000000000000,
0.001570000000000000,0.004110000000000000,0.001920000000000000,
0.026280000000000001,0.004310000000000000,0.002520000000000000,
0.003770000000000000,0.002800000000000000,0.007180000000000000,
0.001600000000000000,0.002770000000000000,0.743559999999999999,
0.059670000000000001,0.019689999999999999,0.007740000000000000,
0.004900000000000000,0.726339999999999986,0.002090000000000000,
0.047960000000000003,0.011390000000000001,0.003980000000000000,
0.003480000000000000,0.001930000000000000,0.001740000000000000,
0.001540000000000000,0.001770000000000000,0.001490000000000000,
0.004390000000000000,0.002000000000000000,0.002550000000000000,
0.004480000000000000,0.056809999999999999
)
, tolerance = 1e-8)
})